#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
#include<queue>
using namespace std;
#define ll long long 
#define MAXL 100005
#define mod 998244353
int main()
{
	int k, n;
	cin >> k;
	while (k--)
	{
		cin >> n;
		if (n == 1 || n == 3 || n == 6 || n == 10)
		{
			if (n == 1)
				cout << "0" << endl;
			else if (n == 3)
				cout << "1" << endl;
			else if (n == 6)
				cout << "2" << endl;
			else
				cout << "3" << endl;
		}
		else
			cout << "-1" << endl;
	}
	return 0;
}